// 在模型定义中添加
const {Model, DataTypes} = require('sequelize');
const sequelize = require('../config/db');

class User extends Model {}
User.init({
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false,
    comment: '用户ID'
  },
  username: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '用户名'
  },
  password: {
    type: DataTypes.STRING(100), // 存储哈希后的密码
    allowNull: false,
    comment: '密码'
  },
  is_admin: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '是否为管理员'
  }
}, {
  sequelize,
  modelName: 'users',
  timestamps: false, // 禁用时间戳
  tableName: 'users' // 指定表名
});

module.exports = User;
